package cn.edu.hqu.cst.lingshou03;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class Config {

    private static final String URL = "jdbc:mysql://localhost:3306/yourdatabase?useSSL=true";
    private static final String SERVER_RSA_PUBLIC_KEY_FILE = "/path/to/server-public-key.pem";

    public static Connection getConnection() throws SQLException {
        Properties properties = new Properties();
        properties.setProperty("serverRsaPublicKeyFile", SERVER_RSA_PUBLIC_KEY_FILE);

        // 注册MySQL JDBC驱动（如果尚未注册）
        try {
            Class.forName("org.mariadb.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new SQLException("MySQL JDBC Driver not found", e);
        }

        // 使用这些属性来建立连接
        return DriverManager.getConnection(URL, properties);
    }
}
